package com.example.librarymanagementproject2.converter;

import com.example.librarymanagementproject2.model.document.BorrowRecordDocument;
import com.example.librarymanagementproject2.model.entity.Book;
import com.example.librarymanagementproject2.model.entity.BorrowRecord;
import com.example.librarymanagementproject2.model.entity.User;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * @InterfaceName BorrowRecordConverter
 * @Description TODO
 * @Author Kx
 * @Date 2025/10/29 9:50
 * @Version 1.0
 */
@Mapper(componentModel = "spring")
public interface BorrowRecordConverter {

    @Mappings({
            @Mapping(source = "borrowRecord.id", target = "id"),
            @Mapping(source = "user.id", target = "userId"),
            @Mapping(source = "user.realName", target = "realName"),
            @Mapping(source = "book.id", target = "bookId"),
            @Mapping(source = "book.title", target = "bookName"),
            @Mapping(source = "borrowRecord.borrowDate", target = "borrowDate"),
            @Mapping(source = "borrowRecord.dueDate", target = "dueDate"),
            @Mapping(source = "borrowRecord.returnDate", target = "returnDate"),
            @Mapping(source = "borrowRecord.status", target = "status"),
            @Mapping(source = "borrowRecord.renewCount", target = "renewCount"),
            @Mapping(source = "borrowRecord.auditStatus", target = "auditStatus"),
            @Mapping(source = "borrowRecord.auditRemark", target = "auditRemark")
    })
    BorrowRecordDocument borrowRecordToBorrowRecordDocument(BorrowRecord borrowRecord, Book book, User user);
}
